-
Notifications
You must be signed in to change notification settings - Fork 46
Fix/72 #75
Conversation
@@ -365,9 +365,16 @@ SearchParameters.prototype = { | |||
* @return {SearchParameters} | |||
*/ | |||
addFacetRefinement : function addFacetRefinement( facet, value ) { | |||
if( this.isRefined( facet, value ) ) { | |||
return this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it return a this.mutateMe(noop)
instead ? So the return of addFacetRefinement
is consistenly a new object ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case isRefined( facet, value ) returns true, it would mean that there would be no changes, so might as well avoid creating a new instance (there are thousands of case we create useless new objects, true :D, it's just continuous improvement here)
Except that, LGTM. 👍 |
👍 LGTM |
if( idx > -1 ) { | ||
m.facetsRefinements[ facet ].splice( idx, 1 ); | ||
if( m.facetsRefinements[ facet ].length === 0 ) { | ||
delete m.facetsRefinements[ facet ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to delete the array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually we remove the key from the object so when iterating with a for in
we don't need to check for the content.
LGTM |
Thanks for the comments :) Merging! |
@redox @pixelastic @jerskouille @maxiloc @vvo Review please? :)